unit F_ProductCoast;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, JvExControls, JvDBLookup, ExtCtrls, Grids, DBGrids, JvExDBGrids,
  JvDBGrid, JvDBUltimGrid, DB, ZAbstractRODataset, ZAbstractDataset,
  ZAbstractTable, ZDataset, JvSpeedButton, StdCtrls;

type
  TProductCoast = class(TForm)
    Panel_Producto: TPanel;
    JvDBLC_Producto: TJvDBLookupCombo;
    Panel_Costo: TPanel;
    JvDBUltimGrid: TJvDBUltimGrid;
    DS_Precio_Producto: TDataSource;
    Label_Producto: TLabel;
    Panel_Opciones: TPanel;
    JvSB_Agregar: TJvSpeedButton;
    PanelInferior: TPanel;
    B_Cerrar: TJvSpeedButton;
    procedure JvSB_AgregarClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure B_CerrarClick(Sender: TObject);
    procedure JvDBLC_ProductoChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


implementation

uses DM_Persistencia, F_ProductCoastInsert;

{$R *.dfm}

procedure TProductCoast.JvSB_AgregarClick(Sender: TObject);
begin
  if (JvDBLC_Producto.KeyValue > 0 ) then
    with TProductCoastInsert.Create(Self, JvDBLC_Producto.KeyValue) do
      if (ShowModal = mrOk) then
        begin
          DM_Persistence.ZT_Detalle_Precio.Close;
          DM_Persistence.ZT_Detalle_Precio.Open;
          DM_Persistence.FormatFields;
          Free;
        end;
end;

procedure TProductCoast.FormCreate(Sender: TObject);
begin
  JvDBLC_Producto.KeyValue:= 1;

  DM_Persistence.FormatFields;
end;

procedure TProductCoast.B_CerrarClick(Sender: TObject);
begin
  Close;
end;

procedure TProductCoast.JvDBLC_ProductoChange(Sender: TObject);
begin
  if (DM_Persistence.ZT_Detalle_Precio.FieldByName('FK_ID_PRODUCTO').AsInteger in [1,2]) then
    TFloatField(DM_Persistence.ZT_Detalle_Precio.FindField('PRECIO')).DisplayFormat := '$ ,0.000'
  else
    TFloatField(DM_Persistence.ZT_Detalle_Precio.FindField('PRECIO')).DisplayFormat := ',0 Copias'
end;

end.
